//
//  OrderTableViewCell.m
//  Free
//
//  Created by 张炜健 on 2018/5/16.
//  Copyright © 2018年 张炜健. All rights reserved.
//

#import "OrderTableViewCell.h"
@interface OrderTableViewCell()
@property (nonatomic,weak)UIImageView *imageL;
@property (nonatomic,weak)UILabel *titleL;
@property (nonatomic,weak)UILabel *priceL;
@property (nonatomic,weak)UILabel *quantityL;
@property (nonatomic,weak)UILabel *detailsL;
@property (nonatomic,weak)UILabel *inventoryNum;//积分百分比
@property (nonatomic,weak)UILabel *inventory;//积分抵折扣
@property (nonatomic,weak)UIImageView *icon_fanLiImageV;
@end




@implementation OrderTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //头片
        UIImageView *image = [[UIImageView alloc]init];
        image.contentMode = UIViewContentModeScaleAspectFit;
        [self.contentView addSubview:image];
//        image.image = PlaceImage;
        self.imageL = image;
        
        UIImageView *image2 = [[UIImageView alloc]init];
        [self.contentView addSubview:image2];
        self.icon_fanLiImageV = image2;
        
        
        
        //标题
        UILabel *lable = [[UILabel alloc]init];
        lable.font = [UIFont systemFontOfSize:14];
        lable.numberOfLines = 2;
        [self.contentView addSubview:lable];
        
        self.titleL = lable;
        //价格
        UILabel *priceLable = [[UILabel alloc]init];
        priceLable.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:priceLable];
        self.priceL = priceLable;
        //数量
        UILabel *numberL = [[UILabel alloc]init];
        numberL.font = [UIFont systemFontOfSize:14];
        numberL.textAlignment = NSTextAlignmentRight ;
        [self.contentView addSubview:numberL];
        self.quantityL = numberL;
        //简介
        UILabel *detailL = [[UILabel alloc]init];
        detailL.font = [UIFont systemFontOfSize:14];
        detailL.textColor = [UIColor lightGrayColor];
        detailL.numberOfLines = 0;
        [self.contentView addSubview:detailL];
        self.detailsL = detailL;
        
        //销售量
        UILabel *inventory = [[UILabel alloc]init];
        //        inventory.backgroundColor = RandomColor;
        inventory.font = [UIFont systemFontOfSize:12];
        inventory.layer.borderWidth = 0.5;
//        inventory.layer.borderColor = MainAppColor.CGColor;
        inventory.backgroundColor = [UIColor whiteColor];
//        inventory.textColor = MainAppColor;
        inventory.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:inventory];
        self.inventory = inventory;
        //销售实际数量
        UILabel *inventoryNum = [[UILabel alloc]init];
        //        inventoryNum.backgroundColor = RandomColor;
        inventoryNum.font = [UIFont systemFontOfSize:12];
//        inventoryNum.backgroundColor = MainAppColor;
        inventoryNum.textAlignment = NSTextAlignmentCenter;
        inventoryNum.textColor = [UIColor whiteColor];
        [self.contentView addSubview:inventoryNum];
        self.inventoryNum = inventoryNum;
        
        
        
    }
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    return self;
}
//-(void)setItem:(AllDetailsItem *)item{
//    _item = item;
//    self.imageL.frame = CGRectMake(15, 10, 60, 60);
//    [self.imageL sd_setImageWithURL:[NSURL URLWithString:item.showImg] placeholderImage:PlaceImage];
//    float titleW = KScreenWidth - self.imageL.right- 10 - 15 ;
//    self.titleL.text = item.showGoodsName;
//    float titleH = [self.titleL.text boundingRectWithSize:CGSizeMake(titleW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName :[UIFont systemFontOfSize:14]} context:nil].size.height;
//    if (titleH>40) {
//        titleH = 40;
//    }
//    self.titleL.frame = CGRectMake(self.imageL.right+10, 10, titleW, titleH);
//
//    self.detailsL.text = item.showOption ;
//    float detailsH = [self.detailsL.text boundingRectWithSize:CGSizeMake(titleW - 30, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName :[UIFont systemFontOfSize:14]} context:nil].size.height;
//    self.detailsL.frame = CGRectMake(self.titleL.xv, self.titleL.bottom+5, titleW -30, detailsH);
//
//    self.priceL.text = [NSString stringWithFormat:@"单价:¥%@",item.actualPrice];
//
//    float priceW =[self.priceL.text sizeWithAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]}].width;
//    self.priceL.frame = CGRectMake(KScreenWidth-priceW-15, self.detailsL.bottom + 5, priceW, 20);
//
//    self.quantityL.frame = CGRectMake(self.detailsL.right, self.detailsL.yv, 30, 20);
//    self.quantityL.text = [NSString stringWithFormat:@"x %@",item.quantity];
//    self.imageL.centerYv = (self.priceL.bottom  -self.titleL.top)/2 + 10 ;
//
//
//    //积分低折扣
//    self.inventory.text = @"茶宝抵扣";
//    CGFloat inventoryW = [self.inventory.text sizeWithAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:12]}].width;
//    self.inventory.frame = CGRectMake(self.detailsL.xv,self.detailsL.bottom + 5, inventoryW + 10 , 20);
//    //折扣百分比
//    self.inventoryNum.text = [NSString stringWithFormat:@"%@%@",item.integralPercent,@"%"];
//    CGFloat inventoryNumW = [self.inventoryNum.text sizeWithAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:12]}].width;
//    self.inventoryNum.frame = CGRectMake(self.inventory.right ,self.inventory.yv, inventoryNumW + 10 , 20);
//    int number = [item.integralPercent intValue];
//    if (number == 100) {
//        self.inventory.layer.borderColor = MainGreenColor.CGColor;
//        self.inventory.textColor =MainGreenColor;
//        self.inventoryNum.backgroundColor = MainGreenColor;
//        self.inventory.hidden = NO;
//        self.inventoryNum.hidden = NO;
//    }else if (number == 0){
//        self.inventory.hidden = YES;
//        self.inventoryNum.hidden = YES;
//    }else{
//        self.inventory.layer.borderColor = MainAppColor.CGColor;
//        self.inventory.textColor =MainAppColor;
//        self.inventoryNum.backgroundColor = MainAppColor;
//        self.inventory.hidden = NO;
//        self.inventoryNum.hidden = NO;
//    }
//
//    self.icon_fanLiImageV.frame =  CGRectMake(self.inventoryNum.right ,self.priceL.yv, 20 , 20);
//    if ([item.rebate intValue] == 1) {
//        if (number == 0) {
//            self.icon_fanLiImageV.xv = self.detailsL.xv;
//        }else{
//            self.icon_fanLiImageV.xv = self.inventoryNum.right;
//        }
//        self.icon_fanLiImageV.image = [UIImage imageNamed:@"rebate"];
//    }
//
//
//
//
//    //cell高度
//    self.cellHight = self.priceL.bottom + 10;
//
//}

@end
